using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class System_Reflection_BindingFlags_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            FieldInfo field;
            Type[] args;
            Type type = typeof(System.Reflection.BindingFlags);

            field = type.GetField("Default", flag);
            app.RegisterCLRFieldGetter(field, get_Default_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_Default_0, null);
            field = type.GetField("IgnoreCase", flag);
            app.RegisterCLRFieldGetter(field, get_IgnoreCase_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_IgnoreCase_1, null);
            field = type.GetField("DeclaredOnly", flag);
            app.RegisterCLRFieldGetter(field, get_DeclaredOnly_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_DeclaredOnly_2, null);
            field = type.GetField("Instance", flag);
            app.RegisterCLRFieldGetter(field, get_Instance_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_Instance_3, null);
            field = type.GetField("Static", flag);
            app.RegisterCLRFieldGetter(field, get_Static_4);
            app.RegisterCLRFieldBinding(field, CopyToStack_Static_4, null);
            field = type.GetField("Public", flag);
            app.RegisterCLRFieldGetter(field, get_Public_5);
            app.RegisterCLRFieldBinding(field, CopyToStack_Public_5, null);
            field = type.GetField("NonPublic", flag);
            app.RegisterCLRFieldGetter(field, get_NonPublic_6);
            app.RegisterCLRFieldBinding(field, CopyToStack_NonPublic_6, null);
            field = type.GetField("FlattenHierarchy", flag);
            app.RegisterCLRFieldGetter(field, get_FlattenHierarchy_7);
            app.RegisterCLRFieldBinding(field, CopyToStack_FlattenHierarchy_7, null);
            field = type.GetField("InvokeMethod", flag);
            app.RegisterCLRFieldGetter(field, get_InvokeMethod_8);
            app.RegisterCLRFieldBinding(field, CopyToStack_InvokeMethod_8, null);
            field = type.GetField("CreateInstance", flag);
            app.RegisterCLRFieldGetter(field, get_CreateInstance_9);
            app.RegisterCLRFieldBinding(field, CopyToStack_CreateInstance_9, null);
            field = type.GetField("GetField", flag);
            app.RegisterCLRFieldGetter(field, get_GetField_10);
            app.RegisterCLRFieldBinding(field, CopyToStack_GetField_10, null);
            field = type.GetField("SetField", flag);
            app.RegisterCLRFieldGetter(field, get_SetField_11);
            app.RegisterCLRFieldBinding(field, CopyToStack_SetField_11, null);
            field = type.GetField("GetProperty", flag);
            app.RegisterCLRFieldGetter(field, get_GetProperty_12);
            app.RegisterCLRFieldBinding(field, CopyToStack_GetProperty_12, null);
            field = type.GetField("SetProperty", flag);
            app.RegisterCLRFieldGetter(field, get_SetProperty_13);
            app.RegisterCLRFieldBinding(field, CopyToStack_SetProperty_13, null);
            field = type.GetField("PutDispProperty", flag);
            app.RegisterCLRFieldGetter(field, get_PutDispProperty_14);
            app.RegisterCLRFieldBinding(field, CopyToStack_PutDispProperty_14, null);
            field = type.GetField("PutRefDispProperty", flag);
            app.RegisterCLRFieldGetter(field, get_PutRefDispProperty_15);
            app.RegisterCLRFieldBinding(field, CopyToStack_PutRefDispProperty_15, null);
            field = type.GetField("ExactBinding", flag);
            app.RegisterCLRFieldGetter(field, get_ExactBinding_16);
            app.RegisterCLRFieldBinding(field, CopyToStack_ExactBinding_16, null);
            field = type.GetField("SuppressChangeType", flag);
            app.RegisterCLRFieldGetter(field, get_SuppressChangeType_17);
            app.RegisterCLRFieldBinding(field, CopyToStack_SuppressChangeType_17, null);
            field = type.GetField("OptionalParamBinding", flag);
            app.RegisterCLRFieldGetter(field, get_OptionalParamBinding_18);
            app.RegisterCLRFieldBinding(field, CopyToStack_OptionalParamBinding_18, null);
            field = type.GetField("IgnoreReturn", flag);
            app.RegisterCLRFieldGetter(field, get_IgnoreReturn_19);
            app.RegisterCLRFieldBinding(field, CopyToStack_IgnoreReturn_19, null);


            app.RegisterCLRCreateDefaultInstance(type, () => new System.Reflection.BindingFlags());
            app.RegisterCLRCreateArrayInstance(type, s => new System.Reflection.BindingFlags[s]);


        }

        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref System.Reflection.BindingFlags instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch(ptr_of_this_method->ObjectType)
            {
                case ObjectTypes.Object:
                    {
                        __mStack[ptr_of_this_method->Value] = instance_of_this_method;
                    }
                    break;
                case ObjectTypes.FieldReference:
                    {
                        var ___obj = __mStack[ptr_of_this_method->Value];
                        if(___obj is ILTypeInstance)
                        {
                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                        }
                        else
                        {
                            var t = __domain.GetType(___obj.GetType()) as CLRType;
                            t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                        }
                    }
                    break;
                case ObjectTypes.StaticFieldReference:
                    {
                        var t = __domain.GetType(ptr_of_this_method->Value);
                        if(t is ILType)
                        {
                            ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                        }
                        else
                        {
                            ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                        }
                    }
                    break;
                 case ObjectTypes.ArrayReference:
                    {
                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Reflection.BindingFlags[];
                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
                    }
                    break;
            }
        }


        static object get_Default_0(ref object o)
        {
            return System.Reflection.BindingFlags.Default;
        }

        static StackObject* CopyToStack_Default_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.Default;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_IgnoreCase_1(ref object o)
        {
            return System.Reflection.BindingFlags.IgnoreCase;
        }

        static StackObject* CopyToStack_IgnoreCase_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.IgnoreCase;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_DeclaredOnly_2(ref object o)
        {
            return System.Reflection.BindingFlags.DeclaredOnly;
        }

        static StackObject* CopyToStack_DeclaredOnly_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.DeclaredOnly;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Instance_3(ref object o)
        {
            return System.Reflection.BindingFlags.Instance;
        }

        static StackObject* CopyToStack_Instance_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.Instance;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Static_4(ref object o)
        {
            return System.Reflection.BindingFlags.Static;
        }

        static StackObject* CopyToStack_Static_4(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.Static;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Public_5(ref object o)
        {
            return System.Reflection.BindingFlags.Public;
        }

        static StackObject* CopyToStack_Public_5(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.Public;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_NonPublic_6(ref object o)
        {
            return System.Reflection.BindingFlags.NonPublic;
        }

        static StackObject* CopyToStack_NonPublic_6(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.NonPublic;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_FlattenHierarchy_7(ref object o)
        {
            return System.Reflection.BindingFlags.FlattenHierarchy;
        }

        static StackObject* CopyToStack_FlattenHierarchy_7(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.FlattenHierarchy;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_InvokeMethod_8(ref object o)
        {
            return System.Reflection.BindingFlags.InvokeMethod;
        }

        static StackObject* CopyToStack_InvokeMethod_8(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.InvokeMethod;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_CreateInstance_9(ref object o)
        {
            return System.Reflection.BindingFlags.CreateInstance;
        }

        static StackObject* CopyToStack_CreateInstance_9(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.CreateInstance;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_GetField_10(ref object o)
        {
            return System.Reflection.BindingFlags.GetField;
        }

        static StackObject* CopyToStack_GetField_10(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.GetField;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_SetField_11(ref object o)
        {
            return System.Reflection.BindingFlags.SetField;
        }

        static StackObject* CopyToStack_SetField_11(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.SetField;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_GetProperty_12(ref object o)
        {
            return System.Reflection.BindingFlags.GetProperty;
        }

        static StackObject* CopyToStack_GetProperty_12(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.GetProperty;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_SetProperty_13(ref object o)
        {
            return System.Reflection.BindingFlags.SetProperty;
        }

        static StackObject* CopyToStack_SetProperty_13(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.SetProperty;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_PutDispProperty_14(ref object o)
        {
            return System.Reflection.BindingFlags.PutDispProperty;
        }

        static StackObject* CopyToStack_PutDispProperty_14(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.PutDispProperty;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_PutRefDispProperty_15(ref object o)
        {
            return System.Reflection.BindingFlags.PutRefDispProperty;
        }

        static StackObject* CopyToStack_PutRefDispProperty_15(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.PutRefDispProperty;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_ExactBinding_16(ref object o)
        {
            return System.Reflection.BindingFlags.ExactBinding;
        }

        static StackObject* CopyToStack_ExactBinding_16(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.ExactBinding;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_SuppressChangeType_17(ref object o)
        {
            return System.Reflection.BindingFlags.SuppressChangeType;
        }

        static StackObject* CopyToStack_SuppressChangeType_17(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.SuppressChangeType;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_OptionalParamBinding_18(ref object o)
        {
            return System.Reflection.BindingFlags.OptionalParamBinding;
        }

        static StackObject* CopyToStack_OptionalParamBinding_18(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.OptionalParamBinding;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_IgnoreReturn_19(ref object o)
        {
            return System.Reflection.BindingFlags.IgnoreReturn;
        }

        static StackObject* CopyToStack_IgnoreReturn_19(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = System.Reflection.BindingFlags.IgnoreReturn;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


        static object PerformMemberwiseClone(ref object o)
        {
            var ins = new System.Reflection.BindingFlags();
            ins = (System.Reflection.BindingFlags)o;
            return ins;
        }


    }
}
